]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dnd: Don't use transformed size to calculate parent scale when restoring
authorSebastian Keller <skeller@gnome.org>
Wed, 31 Mar 2021 02:16:57 +0000 (04:16 +0200)
committerMarge Bot <marge-bot@gnome.org>
Tue, 4 May 2021 15:45:58 +0000 (15:45 +0000)
Some drag actor parents might change their width to 0 after the drag
actor has been removed. If the drag is now canceled and the drag actor
is animated to return to the current parent position and scale, this
scale can not be determined and falls back to 1.0. This might be wrong
and can result in the drag actor being too large/small at the end of the
return animation.

To avoid this calculate the scale of the parent by recursively
calculating the product of its parents individual scales.

Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4017

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1790>

js/ui/dnd.js

index 03b56915f160615b4773b518dbc42743ddf7297e..4f2910da98e260692e701ddfabfe94d37f43cde3 100644 (file)
@@ -56,6 +56,15 @@ function _getEventHandlerActor() {
     return eventHandlerActor;
 }
 
+function _getRealActorScale(actor) {
+    let scale = 1.0;
+    while (actor) {
+        scale *= actor.scale_x;
+        actor = actor.get_parent();
+    }
+    return scale;
+}
+
 function addDragMonitor(monitor) {
     dragMonitors.push(monitor);
 }
@@ -659,11 +668,7 @@ var _Draggable = class _Draggable {
             // its parent, adjusting for the fact that the parent
             // may have been moved or scaled
             let [parentX, parentY] = this._dragOrigParent.get_transformed_position();
-            let [parentWidth] = this._dragOrigParent.get_size();
-            let [parentScaledWidth] = this._dragOrigParent.get_transformed_size();
-            let parentScale = 1.0;
-            if (parentWidth != 0)
-                parentScale = parentScaledWidth / parentWidth;
+            let parentScale = _getRealActorScale(this._dragOrigParent);
 
             x = parentX + parentScale * this._dragOrigX;
             y = parentY + parentScale * this._dragOrigY;